package com.rxyb.hongyu.gateway.enums;

import com.alibaba.fastjson.JSONObject;
import com.rxyb.core.respone.IBaseCode;
import com.rxyb.core.respone.enums.CommonCode;

public enum RspCode implements IBaseCode {
	/** 检车站不存在 */
	MCHNT_NOT_EXSIT("", "检车站不存在"),

	;

	private final String code;
	private final String msg;

	RspCode(final String code, final String msg) {
		this.code = code;
		this.msg = msg;
	}

	public static RspCode fromCode(String code) {
		RspCode[] ecs = RspCode.values();
		for (RspCode ec : ecs) {
			if (ec.getCode().equals(code)) {
				return ec;
			}
		}
		return null;
	}


	/*
	 * 错误编码 -1、失败 0、成功
	 */
	@Override
	public String getCode() {
		return code;
	}

	/*
	 * 错误描述
	 */
	@Override
	public String getMsg() {
		return msg;
	}

	@Override
	public String toString() {
		JSONObject object = new JSONObject();
		object.put("code", code);
		object.put("msg", msg);
		return object.toString();
	}
}
